package edu.scau.cxq.gp.controller;


import com.github.pagehelper.PageInfo;
import edu.scau.cxq.gp.common.annotation.ResponseResult;
import edu.scau.cxq.gp.entity.InventoryAlert;
import edu.scau.cxq.gp.service.IInventoryAlertService;
import edu.scau.cxq.gp.entity.vo.InventoryAlertVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @description 前端控制器
 * @return
 * @author TLC
 */

@RestController
@ResponseResult
@RequestMapping("/inventory-alert")
public class InventoryAlertController {

    @Resource
    private IInventoryAlertService inventoryAlertService;

    /**
     * 根据id删除一条预警记录
     *
     * @param
     * @return
     */
    @PostMapping("/delete")
    public boolean delete(@RequestBody InventoryAlert inventoryAlert) {
        return inventoryAlertService.removeById(inventoryAlert.getAlertId());
    }

    /**
     * 查找库存预警信息
     *
     * @return
     */
    @GetMapping("/select")
    public PageInfo<InventoryAlertVO> select(Integer currentPage, Integer size, @RequestParam(value = "goodsId", required = false) Long goodsId,
                                             @RequestParam(value = "wareId", required = false) Long wareId) {
        PageInfo<InventoryAlertVO> inventoryAlertVOList = inventoryAlertService.getInventoryAlertVOList(currentPage, size, goodsId, wareId);
        return inventoryAlertVOList;
    }
}
